using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace viBook.Models
{
    public class Chapter
    {
        public int Id { get; set; }


        [Required(ErrorMessage = "ChapterName is required.")]
        [MaxLength(125, ErrorMessage = "ChapterName cannot be longer than 125 characters.")]
        public string ChapterName { get; set; }

        [MaxLength(500, ErrorMessage = "Content cannot be longer than 500 characters.")]
        public string Content { get; set; }

        public int ChapterNumber { set; get; }

        [NotMapped]
        public int NumberOfComments { get; set; }
        [NotMapped]
        public int NumberOfLikes { get; set; }
        [NotMapped]
        public int NumberOfViews { get; set; } 
        [NotMapped]
        public string ListSortedPagesId { get; set; }

        //hacked: The order of the following 3 properties can effect the value when insert/update because of ChatperModelBinder
        public virtual IList<Page> Pages { get; set; }
        public string ChapterImage { get; set; }

        [NotMapped]
        public int NumberOfPages { get; set; }

        public int BookId { set; get; }
        public virtual Book Book { get; set; }

        public virtual IEnumerable<ChapterComment> Comments { get; set; }
        public virtual IEnumerable<ChapterComment> Likes { get; set; }
        [NotMapped]
        public virtual bool IsReported { get; set; }

        public bool IsBlocked { get; set; }
        public DateTime UploadedDate { get; set; }

        [NotMapped]
        public virtual string NextChapterName { get; set; }
        [NotMapped]
        public virtual string PreviousChapterName { get; set; }
        [NotMapped]
        public virtual int NextChapterId { get; set; }
        [NotMapped]
        public virtual int PreviousChapterId { get; set; }
        [NotMapped]
        public bool IsLiked { get; set; }
    }
}
